﻿package Objetos 
{
	import flash.display.MovieClip;
	import flash.events.Event;
	/**
	 * ...
	 * @author ...
	 */
	public class Energia extends MovieClip
	{
		
		public function Energia(movieclip:MovieClip) 
		{
			this.x = movieclip.x;
			this.y = movieclip.y + movieclip.height / 2;
		}
		
		public function update(): void
		{
			if (Main.getInstance().IN_delayenergia > 0)
			{
				Main.getInstance().IN_delayenergia --
			}
			
			if (Main.getInstance().IN_delayenergia <= 0)
			{
				this.scaleY -= 0.0005;
				
				if (Heroi.BO_esquerda || Heroi.BO_direita)
				{
					this.scaleY -= 0.005;
				}
			}
			
			if (this.scaleY <= 0)
			{	
				Main.getInstance().MC_heroi.y += 5;
				
				Main.getInstance().SC_canalgameplay.stop();
				
				Main.getInstance().SC_canaldesativamento.stop();
				Main.getInstance().SC_canaldesativamento                = Main.getInstance().SO_desativamento.play();
			    Main.getInstance().ST_transformardesativamento.volume   = 0.5;
			    Main.getInstance().SC_canaldesativamento.soundTransform = Main.getInstance().ST_transformardesativamento;
				
				if (Main.getInstance().MC_heroi.y >= Main.getStage().stage.stageHeight + Main.getInstance().MC_heroi.width)
				{
					Main.getInstance().BO_gameover = true;
				}
			}
		}
	}
}